package com.py.outbound.controller;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.io.IOException;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.py.outbound.domain.WhOutboundDetails;
import com.py.outbound.service.IWhOutboundDetailsService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 【请填写功能名称】Controller
 *
 * @author ruoyi
 * @date 2024-12-23
 */
@RestController
@RequestMapping("/details")
public class WhOutboundDetailsController extends BaseController
{
    @Autowired
    private IWhOutboundDetailsService whOutboundDetailsService;

    /**
     * 查询【请填写功能名称】列表
     */
    @RequiresPermissions("outbound:details:list")
    @GetMapping("/list")
    public TableDataInfo list(WhOutboundDetails whOutboundDetails)
    {
        startPage();
        List<WhOutboundDetails> list = whOutboundDetailsService.selectWhOutboundDetailsList(whOutboundDetails);
        return getDataTable(list);
    }

    /**
     * 导出【请填写功能名称】列表
     */
    @RequiresPermissions("outbound:details:export")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WhOutboundDetails whOutboundDetails)
    {
        List<WhOutboundDetails> list = whOutboundDetailsService.selectWhOutboundDetailsList(whOutboundDetails);
        ExcelUtil<WhOutboundDetails> util = new ExcelUtil<WhOutboundDetails>(WhOutboundDetails.class);
        util.exportExcel(response, list, "【请填写功能名称】数据");
    }

    /**
     * 获取【请填写功能名称】详细信息
     */
    @RequiresPermissions("outbound:details:query")
    @GetMapping(value = "/{detailsId}")
    public AjaxResult getInfo(@PathVariable("detailsId") Long detailsId)
    {
        return success(whOutboundDetailsService.selectWhOutboundDetailsByDetailsId(detailsId));
    }

    /**
     * 新增【请填写功能名称】
     */
    @RequiresPermissions("outbound:details:add")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WhOutboundDetails whOutboundDetails)
    {
        return toAjax(whOutboundDetailsService.insertWhOutboundDetails(whOutboundDetails));
    }

    /**
     * 修改【请填写功能名称】
     */
    @RequiresPermissions("outbound:details:edit")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WhOutboundDetails whOutboundDetails)
    {
        return toAjax(whOutboundDetailsService.updateWhOutboundDetails(whOutboundDetails));
    }

    /**
     * 删除【请填写功能名称】
     */
    @RequiresPermissions("outbound:details:remove")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
    @DeleteMapping("/{outboundCode}")
    public AjaxResult remove(@PathVariable String outboundCode)
    {
        return toAjax(whOutboundDetailsService.deleteWhOutboundDetailsByDetailsId(outboundCode));
    }

    @GetMapping("/getDetails")
    public List<WhOutboundDetails> getDetails(@RequestParam("outboundCode")String outboundCode)
    {
        List<WhOutboundDetails> list = whOutboundDetailsService.selectWhOutboundDetailsByOutBoundCode(outboundCode);

        return list;
    }


}

